package com.whq.security.resp;

public class CommonReturnType<T> {
    //结果状态： 成功：0 失败：-1
    private int status;
    //结果
    private T data;

    private static final int STATUS_SUCCESS = 0;
    private static final int STATUS_FAIL = -1;

    public CommonReturnType(int status) {
        this.status = status;
    }

    public CommonReturnType(int status, T data) {
        this.status = status;
        this.data = data;
    }

    public static <T> CommonReturnType success(T data) {
        return new CommonReturnType(STATUS_SUCCESS, data);
    }

    public static <T> CommonReturnType fail(T data) {
        return new CommonReturnType(STATUS_FAIL, data);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
